﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;
using LogicaNegocios.Manager;

namespace UIWeb.HandlersHtml
{
    /// <summary>
    /// Summary description for GetComentList
    /// </summary>
    public class GetComentList : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            string idParticipanteStr = context.Request.Params["id"];
            context.Response.ContentType = "text/plain";
            context.Response.Write(GetList(int.Parse(idParticipanteStr)));
        }

        private string GetList(int id)
        {
            StringBuilder sb = new StringBuilder();
            ParticipanteManager pm = ParticipanteManager.GetManager();
            List<string> listComentarios = pm.GetAtletaEquipo(id).Comentarios;
            if (listComentarios != null && listComentarios.Count > 0)
            {
                sb.Append("<table>");
                sb.Append("<tr>");
                sb.Append("<td>Comentarios</td>");
                sb.Append("</tr>");

                foreach (string com in listComentarios)
                {
                    sb.Append("<tr>");
                    sb.Append("<td>" + com + "</td>");
                    sb.Append("</tr>");
                }

                sb.Append("</table>");
            }
            else
            {
                sb.Append("No hay comentarios");
            }
            return sb.ToString();
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}